package controller;

import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import pojo.GoodsType;
import service.GoodsTypeService;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;

@Controller
public class GoodsTypeServlet {

    @Autowired
    GoodsTypeService goodsTypeService;

    @RequestMapping("/getType")
    @ResponseBody
    public List<GoodsType> selectGoodsType(){
        List<GoodsType> list = goodsTypeService.selectAll();

        return list;
    }


    @RequestMapping("/asdf")
    @ResponseBody
    public ModelAndView as(){
        List<Date> list = new LinkedList<>();
        list.add(new Date());
        list.add(new Date());
        list.add(new Date());
        PageInfo<Date> pi = new PageInfo<>(list);
        ModelAndView mv = new ModelAndView();
        mv.addObject("page",pi);
        mv.setViewName("forward:/ab.jsp");

        return mv;
    }


}
class A {
    int id;
    String name;

    public A() {
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "A{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }

    public A(int id, String name) {
        this.id = id;
        this.name = name;
    }
}
